package com.alias.model;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Employees implements Serializable {
    public static final long serialVersionUID = -5966618586666474164L;
    private int code;
    private int id;
    private String name;
    private String surname;
    private SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
    private String location;
    private Date birthday = new Date();
    private int age;
    private Country country;
    private Currency salaryCurrency;
    private Boolean gender;
    private String city;
    private String position;
    private double salaryAmount;


    public int getAge() {
        float birthdayDate = Float.valueOf(getBirthday().getTime());
        float today = Float.valueOf(System.currentTimeMillis());
        float ageFloat = (today - birthdayDate) / 31536000000f;
        this.age = Math.round(ageFloat);
        return age - 1;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getStringBirthday() {
        return format.format(getBirthday().getTime());
    }

    public void setStringBirthday(String birthday) {
        try {
            this.setBirthday(this.format.parse(birthday));
        } catch (ParseException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }

    public String getStringGender() {
        if (gender == true) {
            return new String("male");
        } else
            return new String("female");
    }

    public boolean getGender() {
        return gender;
    }

    public void setGender(boolean gender) {
        this.gender = gender;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public Currency getSalaryCurrency() {
        return salaryCurrency;
    }

    public String getStringSalaryCurrency() {
        return salaryCurrency.getCurrency();
    }

    public void setSalaryCurrency(Currency salaryCurrency) {
        this.salaryCurrency = salaryCurrency;
    }

    public double getSalaryAmount() {
        return salaryAmount;
    }

    public void setSalaryAmount(double salaryAmount) {
        this.salaryAmount = salaryAmount;
    }

    public Country getCountry() {
        return country;
    }

    public String getStringCountry() {
        return country.getName();
    }

    public void setCountry(Country country) {
        this.country = country;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}
